#include "syscall.h"

struct test_struct
{
	char arg1;
	int arg2;
};

void myFork(void* s)
{
	int i,j;
	struct test_struct* arg = (struct test_struct*)s;
	for(i=0;i<arg->arg2;i++)
	{
	 //for(j=0;j<100000;j++);
	  PutChar(arg->arg1);
	  //PutInt(arg->arg2);
	  PutChar('\n');
	}
	
//Exit(0);
	//UserThreadExit();
}

int main(int argc,char** argv)
{
  char* c;
  int tid[3];
  int i;
  struct test_struct s1,s2,s3;
  
  int argc2 = 2;
  char* argv2[2];
  argv2[0] = "test/testfork";
  argv2[1] = "2";

  s1.arg1 = 'Z';
  s1.arg2 = 5;
  tid[0] = UserThreadCreate(myFork,&s1);
  

  s2.arg1 = 'A';
  s2.arg2 = 40;
  tid[1] = UserThreadCreate(myFork,&s2);

  s3.arg1 = 'Q';
  s3.arg2 = 5;
  tid[2] = UserThreadCreate(myFork,&s3);
  
	// Attente des threads crées
	for (i = 0 ; i < 3 ; i++)
		UserThreadJoin(i);
	
  return(0);
}
